<template>
	<div class="wrapper">
		<div class="button">
			<div class="icon" @click="searchClick"><i class="el-icon-search" /></div>
			<input type="text" :placeholder="placeholder" v-model="text" />
		</div>
	</div>
</template>

<script>
export default {
	data() {
		return {
			text: ''
		};
	},
	props: {
		placeholder: { type: String, default: '' }
	},
	watch: {
		text() {
			this.$emit('textChange', text);
		}
	},
	methods: {
		searchClick() {
			this.$emit('onSearch', text);
		}
	}
};
</script>

<style lang="less">
.wrapper .button {
	display: inline-block;
	height: 40px;
	width: 40px;
	float: left;
	margin: 0 5px;
	background: #f4f4f4;
	border-radius: 20px;
	text-align: center;
	align-items: center;
	cursor: pointer;
	box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.1);
	overflow: hidden;
	transition: all 0.5s linear;
}
.wrapper .button:hover {
	width: 200px;
}
.wrapper .button .icon {
	display: inline-block;
	height: 40px;
	float: left;
	width: 40px;
	border-radius: 20px;
	box-sizing: border-box;
	line-height: 44px;
	transition: all 0.5s linear;
}
.wrapper .button:hover .icon {
	color: white;
	background: #00bfff;
}
.wrapper .button .icon i {
	font-size: 20px;
}
.wrapper .button input {
	display: inline-block;
	float: left;
	outline: none;
	border: none;
	width: 0px;
	font-size: 14px;
	padding: 0 10px;
	line-height: 30px;
	margin: 5px 0;
	background-color: #f4f4f4;
	border-radius: 15px;
	transition: all 0.5s linear;
}
.wrapper .button:hover input {
	width: 150px;
}
</style>
